home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / SmallEiffel 0.3.3 / SmallEiffel PPC / lib_std / boolean_ref.e < prev    next >
Encoding:
Text File  |  1996-06-13  |  2.1 KB  |  114 lines  |  [TEXT/EDIT]

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class BOOLEAN_REF
  5.    
  6. inherit 
  7.    ANY 
  8.       redefine fill_tagged_out_memory
  9.       end;
  10.    
  11. creation make
  12.  
  13. feature 
  14.  
  15.    item: BOOLEAN;      
  16.      -- Value of Current
  17.  
  18.    make(value: BOOLEAN) is
  19.      -- Initialize object
  20.       do  
  21.      item := value
  22.       end;
  23.  
  24. feature
  25.    
  26.    set_item(value: like item) is
  27.       do
  28.      item := value;
  29.       end;
  30.  
  31.    infix "and" (other : BOOLEAN_REF) : BOOLEAN_REF is
  32.      -- `and' of Current with `other'.
  33.       require
  34.      other /= Void
  35.       do
  36.      !!Result.make (item and other.item)
  37.       end;
  38.  
  39.    infix "and then" (other : BOOLEAN_REF) : BOOLEAN_REF is
  40.      -- Semi-strict `and' of Current with `other'.
  41.       require
  42.      other /= Void
  43.       do
  44.      !!Result.make (item and then other.item)
  45.       end;
  46.  
  47.    infix "implies" (other : BOOLEAN_REF) : BOOLEAN_REF is
  48.      -- Does Current imply `other'.
  49.       require
  50.      other /= Void
  51.       do
  52.      !!Result.make (item implies other.item)
  53.       end;
  54.  
  55.    infix "or" (other : BOOLEAN_REF) : BOOLEAN_REF is
  56.      -- `or' of Current with `other'
  57.       require
  58.      other_not_void : other /= Void
  59.       do
  60.      !!Result.make (item or other.item)
  61.       end;
  62.  
  63.    infix "or else" (other : BOOLEAN_REF) : BOOLEAN_REF is
  64.      -- Semi-strict `or' of Current with `other'
  65.       require
  66.      other_not_void : other /= Void
  67.       do
  68.      !!Result.make (item or else other.item)
  69.       end;
  70.  
  71.    infix "xor" (other: BOOLEAN_REF): BOOLEAN_REF is
  72.      -- `xor' of Current with `other'
  73.       require
  74.      other /= Void
  75.       do
  76.      !!Result.make (item xor other.item)
  77.       end;
  78.  
  79.    prefix "not": BOOLEAN_REF is
  80.      -- `not' of Current.
  81.       do
  82.      !!Result.make(not item)
  83.       end;
  84.  
  85.    fill_tagged_out_memory is
  86.       do
  87.      tagged_out_memory.append("item: ");
  88.      if item then
  89.         tagged_out_memory.append("true");
  90.      else     
  91.         tagged_out_memory.append("false");
  92.      end;
  93.       end;
  94.  
  95.    to_string: STRING is
  96.       do
  97.      if Current.item then
  98.         Result := "true";
  99.      else
  100.         Result := "false";
  101.      end;
  102.       end;
  103.    
  104.    to_integer: INTEGER is
  105.       do
  106.      if Current.item then
  107.         Result := 1;
  108.      else
  109.         Result := 0;
  110.      end;
  111.       end;
  112.    
  113. end -- BOOLEAN_REF
  114.